#include "mainwindow.h"
#include "ui_mainwindow.h"

#include<QToolBar>

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    //创建工具栏并设置
    QToolBar* toolBar1 = new QToolBar();
    QToolBar* toolBar2 = new QToolBar();
    //设置工具栏2时设置初始位置在左侧边缘
    this->addToolBar(toolBar1);
    this->addToolBar(Qt::LeftToolBarArea,toolBar2);

    //设置工具栏2允许停靠的边缘(左边和右边)
    toolBar2->setAllowedAreas(Qt::LeftToolBarArea | Qt::RightToolBarArea);
    //设置工具栏2不允许浮动
    toolBar2->setFloatable(false);
    //设置工具栏2不允许移动
    toolBar2->setMovable(false);

    //创建菜单项并设置
    QAction* action1 = new QAction("菜单项1");
    QAction* action2 = new QAction("菜单项2");
    QAction* action3 = new QAction("菜单项3");
    QAction* action4 = new QAction("菜单项4");
    toolBar1->addAction(action1);
    toolBar1->addAction(action2);
    toolBar2->addAction(action3);
    toolBar2->addAction(action4);


}

MainWindow::~MainWindow()
{
    delete ui;
}

